package BLL.User;


import BIZ.UserBiz;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;

@WebServlet(name = "ForgetPwd", value = "/ForgetPwd")
public class ForgetPwd extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public ForgetPwd() {
        super();
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        HttpSession session = request.getSession();


        //从表单获取邮箱
        String Email = new String(request.getParameter("Email").getBytes(StandardCharsets.UTF_8));
        String UserName = new String(request.getParameter("UserName").getBytes(StandardCharsets.UTF_8));

        PrintWriter out = response.getWriter();
        UserBiz userBiz = new UserBiz();
        if (Email.equals(userBiz.getEmail(UserName))) {
            out.println("1");
        } else {
            out.println("0");
        }

    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

}
